<template>
  <div>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in bannerList" :key="item.id">
        <img :src="item.image" alt="轮播图" style="width:100%;height:100%" />
      </van-swipe-item>
    </van-swipe>
    <div class="more">
      <div class="all-title">全部综艺</div>
      <div>更多</div>
    </div>
    <ul class="box" v-if="hotList.length > 0">
      <li class="item-one" v-for="item in hotList" :key="item.id">
        <img :src="item.image" alt="图片" />
        <p>{{ item.name }}</p>
        <div class="section">{{ item.section }}</div>
        <div class="isv">{{ item.free === 1 ? "免费" : "vip" }}</div>
      </li>
    </ul>
    <van-empty v-else description="暂无数据" />
  </div>
</template>

<script>
import televisionApi from "@/api/home/televisionFont";
export default {
  name: "variety",
  data() {
    return {
      bannerList: [],
      hotList: [],
    };
  },
  created() {
    this.getBannerList();
    this.getHotList();
  },
  methods: {
    async getBannerList() {
      let res = await televisionApi.getBanner();
      if (res.code === 20000) {
        this.bannerList = res.data.data;
      } else {
        this.$toast(res.msg);
      }
    },
    async getHotList() {
      let res = await televisionApi.getHot();
      if (res.code === 20000) {
        this.hotList = res.data.data;
      } else {
        this.$toast(res.msg);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  height: 180px;
  line-height: 180px;
  text-align: center;
  background-color: #39a9ed;
}
.more {
  width: 100%;
  height: 0.8rem;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.3rem;
  .all-title {
    width: 80px;
    text-align: center;
    border-left: 3px solid #9fc6ff;
  }
}
.box {
  width: 100%;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  .item-one {
    width: 3.4rem;
    height: 2.4rem;
    margin-bottom: 5px;
    position: relative;
    img {
      width: 100%;
      height: 2rem;
    }
    p {
      width: 100%;
      height: 0.4rem;
      line-height: 0.4rem;
      font-size: 12px;
    }
    .section {
      position: absolute;
      padding: 0 5px;
      right: 10px;
      bottom: 30px;
      background-color: rgba(162, 162, 182, 0.5);
      font-size: 12px;
      color: #fff;
    }
    .isv {
      position: absolute;
      left: 5px;
      top: 5px;
      color: chartreuse;
      font-size: 12px;
    }
  }
}
</style>